package com.meihuayishu.backend.dto;

import lombok.Data;
import lombok.Builder;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "占卜记录详情响应")
public class DivinationRecordDetailResponse {
    
    @Schema(description = "记录ID", example = "rec_1704097800789")
    private String recordId;
    
    @Schema(description = "占卜问题", example = "今年的事业发展怎么样？")
    private String question;
    
    @Schema(description = "占卜类型", example = "TEXT")
    private String divinationType;
    
    @Schema(description = "算法类型", example = "TEXT_HASH")
    private String algorithm;
    
    @Schema(description = "输入数据")
    private Map<String, Object> inputData;
    
    @Schema(description = "卦象信息")
    private HexagramDetail hexagram;
    
    @Schema(description = "AI解读信息")
    private AiInterpretationInfo aiInterpretation;
    
    @Schema(description = "是否收藏", example = "false")
    private Boolean isFavorite;
    
    @Schema(description = "标签")
    private List<String> tags;
    
    @Schema(description = "反馈评分", example = "4")
    private Integer feedbackRating;
    
    @Schema(description = "反馈评论")
    private String feedbackComment;
    
    @Schema(description = "分享次数", example = "2")
    private Integer shareCount;
    
    @Schema(description = "查看次数", example = "5")
    private Integer viewCount;
    
    @Schema(description = "创建时间", example = "2024-01-01T11:10:00.000Z")
    private LocalDateTime createdAt;
    
    @Schema(description = "更新时间", example = "2024-01-01T11:10:00.000Z")
    private LocalDateTime updatedAt;
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "卦象详细信息")
    public static class HexagramDetail {
        @Schema(description = "卦象ID", example = "14")
        private Integer id;
        
        @Schema(description = "卦象名称", example = "火天大有")
        private String name;
        
        @Schema(description = "卦象编码", example = "HUO_TIAN_DA_YOU")
        private String code;
        
        @Schema(description = "上卦信息")
        private TrigramInfo upperTrigram;
        
        @Schema(description = "下卦信息")
        private TrigramInfo lowerTrigram;
        
        @Schema(description = "卦辞", example = "火在天上，大有；君子以遏恶扬善，顺天休命")
        private String hexagramText;
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "八卦信息")
    public static class TrigramInfo {
        @Schema(description = "八卦名称", example = "离")
        private String name;
        
        @Schema(description = "八卦符号", example = "☲")
        private String symbol;
        
        @Schema(description = "对应五行", example = "火")
        private String element;
    }
    
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "AI解读信息")
    public static class AiInterpretationInfo {
        @Schema(description = "解读ID", example = "ai_1704097200123")
        private String interpretationId;
        
        @Schema(description = "解读摘要", example = "火天大有卦预示事业发展整体向好...")
        private String summary;
        
        @Schema(description = "置信度", example = "0.85")
        private Double confidence;
        
        @Schema(description = "生成时间", example = "2024-01-01T10:50:00.000Z")
        private LocalDateTime generatedAt;
    }
}